package com.jeeccm.modules.web.jwt.dto;

import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 *  客户端提交的常规参数
 * @author Administrator
 * @version 1.0
 * @date 2018/06/20 16:35
 */
public class ClientDTO {

    /**
     * 用户主键ID
     */
    private String userId;

    /**
     * 用户名
     */
    private String userName;

    /**
     * token
     */
    private String token;

    /**
     * 密码
     */
    private String password;

    /**
     * 验证码
     */
    private String verifyCode;

    /**
     * 手机号码
     */
    private String phone;
    /**
     * 操作终端
     * 1.web、2.Android手机、3.Android平板、4.IOS手机、5.IOS平板6.WPhone手机、7.WPhone平板
     */
    private Integer optTerminal;

    /**
     * 终端设备
     */
    private String terminalDevice;

    /**
     * 终端厂商
     */
    private String terminalFactory;
    /**
     * 终端唯一码
     */
    private String terminalSn;

    /**
     * 浏览器
     */
    private String browser;

    /**
     * 分辨率
     */
    private String resolution;

    /**
     * 版本号
     */
    private String version;

    /**
     * 当前页
     */
    private Integer nowPage;

    /**
     * 一页显示条数
     */
    private Integer onePageCount;

    /**
     * IP
     */
    private String ip;

    /**
     * 签名标识
     * "URL + USERID + Token + timeStamp =  生成MD5加密串 如：MD5(/admin/tpUser/updateUser?userId=1&token=123ertddd456&timestamp=20160810170830) = 5DIWAIASGDESDEEGE"
     */
    private String sign;

    /**
     * 时间戳
     * 前端请求时间戳
     */
    private Long timeStamp;

    public ClientDTO(ClientBuilder builder) {
        this.userId = builder.userId;
        this.userName = builder.userName;
        this.password = builder.password;
        this.verifyCode = builder.verifyCode;
        this.phone = builder.phone;
        this.optTerminal = builder.optTerminal;
        this.terminalDevice = builder.terminalDevice;
        this.terminalFactory = builder.terminalFactory;
        this.terminalSn = builder.terminalSn;
        this.browser = builder.browser;
        this.resolution = builder.resolution;
        this.version = builder.version;
        this.nowPage = builder.nowPage;
        this.onePageCount = builder.onePageCount;
        this.ip = builder.ip;
        this.sign = builder.sign;
        this.timeStamp = builder.timeStamp;
    }

    public String getUserId() {
        return userId;
    }

    public String getUserName() {
        return userName;
    }

    public String getToken() {
        return token;
    }

    public String getPassword() {
        return password;
    }

    public String getVerifyCode() {
        return verifyCode;
    }

    public String getPhone() {
        return phone;
    }

    public Integer getOptTerminal() {
        return optTerminal;
    }

    public String getTerminalDevice() {
        return terminalDevice;
    }

    public String getTerminalFactory() {
        return terminalFactory;
    }

    public String getTerminalSn() {
        return terminalSn;
    }

    public String getBrowser() {
        return browser;
    }

    public String getResolution() {
        return resolution;
    }

    public String getVersion() {
        return version;
    }

    public Integer getNowPage() {
        return nowPage;
    }

    public Integer getOnePageCount() {
        return onePageCount;
    }

    public String getIp() {
        return ip;
    }

    public String getSign() {
        return sign;
    }

    public Long getTimeStamp() {
        return timeStamp;
    }

    public static class ClientBuilder implements com.jeeccm.modules.core.builder.Builder<ClientDTO> {

        private String userId;
        private String userName;
        private String token;
        private String password;
        private String verifyCode;
        private String phone;
        private Integer optTerminal;
        private String terminalDevice;
        private String terminalFactory;
        private String terminalSn;
        private String browser;
        private String resolution;
        private String version;
        private Integer nowPage;
        private Integer onePageCount;
        private String ip;
        private String sign;
        private Long timeStamp;

        public ClientBuilder(final String userId, final String token){
            this.userId = userId;
            this.token = token;
        }

        public ClientBuilder(final String userId,final String userName,final String token,
                             final String password,final String ip,
                             final String version,final String sign,final Long timeStamp) {
            this.userId = userId;
            this.userName = userName;
            this.token = token;
            this.password = password;
            this.ip = ip;
            this.version = version;
            this.sign = sign;
            this.timeStamp = timeStamp;
        }

        public ClientBuilder verifyCode(final String verifyCode) {
            this.verifyCode = verifyCode;
            return this;
        }

        public ClientBuilder phone(final String phone){
            this.phone = phone;
            return this;
        }

        public ClientBuilder optTerminal(final Integer optTerminal){
            this.optTerminal = optTerminal;
            return this;
        }

        public ClientBuilder terminalDevice(final String terminalDevice){
            this.terminalDevice = terminalDevice;
            return this;
        }

        public ClientBuilder terminalFactory(final String terminalFactory){
            this.terminalFactory = terminalFactory;
            return this;
        }

        public ClientBuilder terminalSn(final String terminalSn){
            this.terminalSn = terminalSn;
            return this;
        }

        public ClientBuilder browser(final String browser){
            this.browser = browser;
            return this;
        }


        public ClientBuilder resolution(final String resolution){
            this.resolution = resolution;
            return this;
        }

        public ClientBuilder nowPage(final Integer nowPage){
            this.nowPage = nowPage;
            return this;
        }

        public ClientBuilder onePageCount(final Integer onePageCount){
            this.onePageCount = onePageCount;
            return this;
        }

        @Override
        public ClientDTO builder() {
            return new ClientDTO(this);
        }
    }


    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("userId", userId)
                .append("userName", userName)
                .append("password", password)
                .append("verifyCode", verifyCode)
                .append("phone", phone)
                .append("optTerminal", optTerminal)
                .append("terminalDevice", terminalDevice)
                .append("terminalFactory", terminalFactory)
                .append("terminalSn", terminalSn)
                .append("browser", browser)
                .append("resolution", resolution)
                .append("version", version)
                .append("nowPage", nowPage)
                .append("onePageCount", onePageCount)
                .append("ip", ip)
                .append("sign", sign)
                .append("timeStamp", timeStamp)
                .toString();
    }
}
